<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <button>登录</button>
    <script>
      //需求 点击按钮让背景变红色
      //
      var btn = document.querySelector('button');
      btn.onclick = function () {
        //this 在函数中 代表函数源
        this.style.background = 'red';
      };
    </script>
  </body>
</html>
